package com.shzu.jwc.ty.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shzu.jwc.ty.bean.SystemNotice;
import com.shzu.jwc.ty.common.Msg;
import com.shzu.jwc.ty.service.SystemNoticeservice;

@Controller
@RequestMapping("fixsystemnotice")
public class FixSystemNoticecontroller {
	@Autowired
	SystemNoticeservice systemNoticeservice;
	
	@RequestMapping("/notice.action")
	public String shownotice(Model model)
	{
		List<SystemNotice> data=systemNoticeservice.getnotice(1);
		model.addAttribute("data", data);
		return "fixsystemnotice/notice";
	}
	
	@ResponseBody
	@RequestMapping("/getone.action")
	public Msg getone(@RequestParam("systemNoticeId")Integer systemNoticeId) {
		SystemNotice systemNotice=systemNoticeservice.getone(systemNoticeId);
		return Msg.success("成功").add("systemNotice", systemNotice);
	}

	@ResponseBody
	@RequestMapping("/updfun.action")
	public Msg updatefun(@RequestParam("systemNoticeContent")String systemNoticeContent,@RequestParam("systemNoticeId") Integer systemNoticeId) {
		try{
			systemNoticeservice.updatecontext(systemNoticeId,systemNoticeContent);
			return Msg.success("操作成功");
		}catch(Exception ex){
			return Msg.success("操作失败,"+ex.getMessage());
		}
	}
}
